<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.lmpop.trade.ti_goods.*" %>
<%@page import="java.util.*" %>
<%@page import="com.lmpop.trade.ts_category.Ts_categoryInfo" %>
<%@page import="com.lmpop.trade.ti_member.*" %>
<%@page import="com.lmpop.frame.util.PageTools" %>
<%@page import="com.lmpop.trade.ti_attach.Ti_attachInfo" %>


<%
	request.setCharacterEncoding("UTF-8");
	
	String s_cust_id = "";	
	if( session.getAttribute("session_cust_id") != null ){
		s_cust_id = session.getAttribute("session_cust_id").toString();
	}
	Ti_goods ti_goods = new Ti_goods();
	
	Ti_goodsInfo ti_goodsInfo = new Ti_goodsInfo();
	Ts_categoryInfo  ts_categoryInfo  = new Ts_categoryInfo();
    Ti_memberInfo  ti_customerInfo  = new Ti_memberInfo();
    Ti_attachInfo  ti_attachInfo = new Ti_attachInfo(); 

	Hashtable pMap =new Hashtable();
    String  s_goods_name="",s_class_attr="",s_goods_sate="",s_start_date="",s_end_date="";
    String  s_cust_name="",s_shelf="",s_recom="",s_s_price="",s_q_price="",s_fresh="",s_appman="";                          
  if(request.getParameter("s_goods_name")!=null && !request.getParameter("s_goods_name").equals("") )
  {
     s_goods_name = request.getParameter("s_goods_name").toString();
     pMap.put("s_goods_name",s_goods_name);  
  }
  if(request.getParameter("s_class_attr")!=null && !request.getParameter("s_class_attr").equals("") )
  {
     s_class_attr = request.getParameter("s_class_attr").toString();
     pMap.put("s_class_attr",s_class_attr);  
  }
  if(request.getParameter("s_goods_sate")!=null && !request.getParameter("s_goods_sate").equals("") )
  {
     s_goods_sate = request.getParameter("s_goods_sate").toString();
     pMap.put("s_goods_sate",s_goods_sate);  
  } 
  if(request.getParameter("s_start_date")!=null && !request.getParameter("s_start_date").equals("") )
  {
     s_start_date = request.getParameter("s_start_date").toString();
     pMap.put("s_start_date",s_start_date);  
  } 
  if(request.getParameter("s_end_date")!=null && !request.getParameter("s_end_date").equals("") )
  {
     s_end_date = request.getParameter("s_end_date").toString();
     pMap.put("s_end_date",s_end_date);  
  }
  
  if(request.getParameter("s_appman")!=null && !request.getParameter("s_appman").equals("") )
  {
     s_appman = request.getParameter("s_appman").toString();
     if(s_appman.equals("noe"))
     {
        pMap.put("no_s_appman","e");
     }
     else
     {
       pMap.put("s_appman",s_appman);
     }    
     
  }
  
  if(request.getParameter("s_shelf")!=null && !request.getParameter("s_shelf").equals("") )
  {
     s_shelf = request.getParameter("s_shelf").toString();
     if(s_shelf.equals("nof"))
     {
        pMap.put("no_s_shelf","f");
     }
     else
     {
       pMap.put("s_shelf",s_shelf);
     }    
     
  }
  if(request.getParameter("s_recom")!=null && !request.getParameter("s_recom").equals("") )
  {
     s_recom = request.getParameter("s_recom").toString();
     if(s_recom.equals("noh"))
     {
        pMap.put("no_s_recom","h");
     }
     else
     {
        pMap.put("s_recom",s_recom);
     }    
  }
  if(request.getParameter("s_s_price")!=null && !request.getParameter("s_s_price").equals("") )
  {
     s_s_price = request.getParameter("s_s_price").toString();
     if(s_s_price.equals("noi"))
     {
        pMap.put("no_s_s_price","i");
     }
     else
     {
         pMap.put("s_s_price",s_s_price); 
     }  
  }
  if(request.getParameter("s_q_price")!=null && !request.getParameter("s_q_price").equals("") )
  {
     s_q_price = request.getParameter("s_q_price").toString();
     if(s_q_price.equals("noj"))
     {
        pMap.put("no_s_q_price","j");
     }
     else
     {
         pMap.put("s_q_price",s_q_price);
 
     }  
  
  }
  if(request.getParameter("s_fresh")!=null && !request.getParameter("s_fresh").equals("") )
  {
     s_fresh = request.getParameter("s_fresh").toString();
     if(s_fresh.equals("nok"))
     {
        pMap.put("no_s_fresh","k");
     }
     else
     {
         pMap.put("s_fresh",s_fresh);
     }  
  
  }
  if(request.getParameter("s_cust_name")!=null && !request.getParameter("s_cust_name").equals("") )
  {
     s_cust_name = request.getParameter("s_cust_name").toString();
     pMap.put("s_cust_name",s_cust_name);  
  }
  
    pMap.put("v_state","a");
	String iStart = "0";
	int limit = 20;
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
	
	String listOrImg = "1";
	if (request.getParameter("listOrImg") != null) {listOrImg = request.getParameter("listOrImg");}
	
	List list = ti_goodsInfo.getListByPage(pMap,Integer.parseInt(iStart),limit);
	int counter = ti_goodsInfo.getCountByObj(pMap);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?listOrImg="+listOrImg+"&s_cust_name="+s_cust_name+"&s_fresh="+s_fresh+"&s_q_price="+s_q_price+"&s_appman="+s_appman+"&s_s_price="+s_s_price+"&s_recom="+s_recom+"&s_shelf="+s_shelf+"&s_end_date="+s_end_date+"&s_start_date="+s_start_date+"&s_goods_sate="+s_goods_sate+"&s_goods_name="+s_goods_name+"&s_class_attr="+s_class_attr+"&iStart=",Integer.parseInt(iStart),limit);
    
	Map catMap = ts_categoryInfo.getCatClassMap("2");
    String para ="";
    
	//String para =	"listOrImg="+listOrImg+"&s_cust_name="+s_cust_name+"&s_fresh="+s_fresh+"&s_q_price="+s_q_price+"&s_s_price="+s_s_price+"&s_recom="+s_recom+"&s_shelf="+s_shelf+"&s_end_date="+s_end_date+"&s_start_date="+s_start_date+"&s_goods_sate="+s_goods_sate+"&s_goods_name="+s_goods_name+"&s_class_attr="+s_class_attr+"&iStart="+Integer.parseInt(iStart)+"&limit="+limit;		 
    //out.print(para);                                               
                                                    
%>
<html>
  <head>
  <title>商品审核列表</title>
	<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
	<link href="/program/admin/index/css/goods_state.css" rel="stylesheet" type="text/css">
	<link href="/program/admin/index/css/thickbox.css" rel="stylesheet" type="text/css">
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/Ts_categoryInfo.js'></script>   
	<script type="text/javascript" src="js_goods.js"></script>
    <script type="text/javascript" src="/js/jquery.js"></script>
    <script type="text/javascript" src="/js/thickbox.js"></script>
    <script language="javascript" type="text/javascript" src="/program/plugins/calendar/WdatePicker.js"></script>
    <script>
   	    jQuery.noConflict();
     </script> 
 </head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="90%">
				<h1>商品审核</h1>
			</td>
			<td>
		
			</td>
		</tr>
	</table>
	<form action="index.jsp" name="indexForm" method="post">
	<table width="100%" cellpadding="0" cellspacing="0"  class="dl_su">
		<tr>
			<td align="left">
				    商品名称:<input name="s_goods_name" id="s_goods_name" type="text" />
				   
 	          &nbsp;商品分类:
				    <select name="sort1" id="sort1" onclick="setSecondClass(this.value);" >
							  <option value="">请选择</option>
					  </select>	
						<select name="sort2" id="sort2" onclick="setTherdClass(this.value);">
							  <option value="">请选择</option>
						</select>		
						<select name="sort3" id="sort3">
							  <option value="">请选择</option>
						</select>
					  <input type="hidden" name="s_class_attr" id="s_class_attr" value=""/>			
			       <script type="text/javascript" src="s_classify.js"></script>

					   &nbsp;商品状态:
                    <select name="s_goods_sate" id="s_goods_sate">
				  	 <option value="">请选择...</option>	
				  	 <option value="a">未审核</option>
				  	 <option value="b">审核未通过</option>
				    </select>	
					
						<br/>
						发布商家:<input name="s_cust_name" id="s_cust_name" type="text" />
				    
            &nbsp;发布时间段:
				    <input name="s_start_date" type="text" id="s_start_date" class="Wdate" value="" onClick="WdatePicker({maxDate:'#F{$dp.$D(\'s_end_date\',{d:-1})}',readOnly:true})" size="15"  width="150px"/>
              -
	          <input name="s_end_date" id="s_end_date" type="text" class="Wdate" value="" onClick="WdatePicker({minDate:'#F{$dp.$D(\'s_start_date\',{d:1})}',readOnly:true})" size="15" width="150px"/>
            
			  <input name="searchInfo" type="button" value="查询" onClick="searchForm()" />	
			</td>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" border="0"  class="tablehe">
		<tr><td align="center"><%=pageString %></td></tr>
	</table>
	
	<% 
		int listsize = 0;
		if(list!=null && list.size()>0){
			listsize = list.size();
	%>
	
	<table width="100%" cellpadding="1" cellspacing="1" border="0" class="dl_bg">
		<tr>
			<td width="85%">
				&nbsp;&nbsp;
			    	<select name="up_operating" id="up_operating">
				  	 <option value="">请选择...</option>	
					 <option value="-">删除</option>	
					 <option value="c">审核通过</option>
					 <option value="b">审核不通过</option>
				    </select>	
				
				<input type="button" name="delInfo" onClick="delIndexInfos('up')" value="确定"  class="buttab" />
				
                                                                                             			
			</td>
			<td>
				总计:<%=counter %>条
			
	            <%if(listOrImg.equals("1")){%>
				<a href="index.jsp?listOrImg=0&s_cust_name=<%=s_cust_name%>&s_fresh=<%=s_fresh%>&s_q_price=<%=s_q_price%>&s_s_price=<%=s_s_price%>&s_recom=<%=s_recom%>&s_shelf=<%=s_shelf%>&s_end_date=<%=s_end_date%>&s_start_date=<%=s_start_date%>&s_goods_sate=<%=s_goods_sate%>&s_goods_name=<%=s_goods_name%>&s_class_attr=<%=s_class_attr%>&iStart=<%=Integer.parseInt(iStart)%>"><img src="/program/admin/images/Onlist.jpg" style="cursor:pointer;" border="0" title="列表显示" /></a>
				<img src="/program/admin/images/Unimglist.jpg" style="cursor:pointer;" border="0" title="图文显示" />
				<%}else if(listOrImg.equals("0")){%>
				<img src="/program/admin/images/Outlist.jpg" style="cursor:pointer;" border="0" title="列表显示" />
				<a href="index.jsp?listOrImg=1&s_cust_name=<%=s_cust_name%>&s_fresh=<%=s_fresh%>&s_q_price=<%=s_q_price%>&s_s_price=<%=s_s_price%>&s_recom=<%=s_recom%>&s_shelf=<%=s_shelf%>&s_end_date=<%=s_end_date%>&s_start_date=<%=s_start_date%>&s_goods_sate=<%=s_goods_sate%>&s_goods_name=<%=s_goods_name%>&s_class_attr=<%=s_class_attr%>&iStart=<%=Integer.parseInt(iStart)%>"><img src="/program/admin/images/Imglist.jpg" style="cursor:pointer;" border="0" title="图文显示" /></a>
				<%}%>
			
			
			
			
			</td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
			<th  align="center"><input type="checkbox" name="checkall" id="checkall" onClick="selectAll()"></th>
			
		  	<%
		  	 if(listOrImg.equals("1")){
		  	%>
		  	<th>商品图片</th>
		  	<%
		  	  }
		  	%>
		  	
		  	<th>商品信息</th>
		  	<th>审核信息</th>	  	
		  	<th>状态</th>
            
			<th>操作</th>
	  		
	  		</tr>
		
		
		<% 
		  		for(int i=0;i<list.size();i++){
		  			Hashtable map = (Hashtable)list.get(i);
		  			String goods_id="",goods_no="",cust_id="",class_attr="",brand_id="",goods_name="",member_price="",org_price="",market_price="",sale_price="";
		  			String send_inter="",buy_inter="",weight="",stock_in="",stock_num="",stock_out="",stock_down="",price_unit="",state_code="",state_date="",ship_fare="",keywords="",outline="",goods_desc="",remark="",link_goods="",link_fit="",attr_desc="",rsrv_str1="",rsrv_str2="",rsrv_str3="",rsrv_str4="",rsrv_str5="",rsrv_str6="",publish_date="",publish_user_id="";
		  			if(map.get("goods_id")!=null) goods_id = map.get("goods_id").toString();
				  	if(map.get("goods_no")!=null) goods_no = map.get("goods_no").toString();
				  	if(map.get("cust_id")!=null) cust_id = map.get("cust_id").toString();
				  	if(map.get("class_attr")!=null) class_attr = map.get("class_attr").toString();
            if(map.get("sale_price")!=null) sale_price = map.get("sale_price").toString();
            if(map.get("send_inter")!=null) send_inter = map.get("send_inter").toString();
				  	if(map.get("state_code")!=null) state_code = map.get("state_code").toString();
				  	if(map.get("remark")!=null) remark = map.get("remark").toString();
					
					String state_codex ="";
					
					if(state_code.equals("a")){state_codex ="<font color='red'>未审核</font>";}
                    if(state_code.equals("b")){state_codex ="<font color='#34ACF3'>未通过</font>";}
					if(state_code.equals("c")){state_codex ="<font color='#34ACF3'>通过</font>";}
					
					
					
				  	StringBuffer catAttr =new StringBuffer();
				    if(!class_attr.equals(""))
					{
						String catIds[] =	class_attr.split("\\|");	
						for(String catId:catIds)
						{
							 if(catMap!=null)
							 {
								if(catMap.get(catId)!=null)
								{
									catAttr.append(catMap.get(catId).toString()+" ");                 
								}                  
							 
							  }                 
						 }		    
				    }

				  	String compnay ="";
					if(!cust_id.equals(""))
					{
					   compnay  = ti_customerInfo.getCustNameByPk(cust_id);         
					}
							
				  	if(map.get("goods_name")!=null)
				  	{
				  	   goods_name = map.get("goods_name").toString();
					   if(goods_name.length()>32)
					   {
						   goods_name = goods_name.substring(0,32);              
					   }
                    }				  	
				  	if(map.get("state_code")!=null) state_code = map.get("state_code").toString();
                                                                               				  	
				  	if(map.get("publish_date")!=null) publish_date = map.get("publish_date").toString();
                    if(publish_date.length()>10)publish_date=publish_date.substring(0,10);
            
                    String img_path =  ti_attachInfo.getFilePathByAttachrootid(goods_id);
					if(img_path.equals(""))
					{
						 img_path ="/program/admin/images/cpwu.gif";            
					}                                                           
                                                                                   
		  %>
		
		<tr>
			<td width="3%" align="center">
				<input type="checkbox" name="checkone<%=i %>" id="checkone<%=i %>" value="<%=goods_id %>" />
			  <input type="hidden" name="stateone<%=i %>" id="stateone<%=i %>" value="<%=state_code %>" />
			</td>
			  <%
		  	 if(listOrImg.equals("1"))
		  	 {
		  	%>
		  	<td width="10%"><img src="<%=img_path%>" border="0" width="85" height="85" /></td>
        <%
		  	  }
		  	%>
		  
		  	<td width="57%">
		  	<a href="updateInfo.jsp?goods_id=<%=goods_id %>" class="infotitle"><%=goods_name%></a>		       
		       
         <span style="color:#303A43;"> 发布日期:</span> <span style="color:#666666;"> <%=publish_date%>		</span>       
           <%
		          if(listOrImg.equals("0") && !img_path.equals(""))
		          {
		        %>
		          <img src="/program/images/ico_img.gif" border="0" />       
		       
		        <%}%>             
		         <div style="margin-top:8px;"></div> 		  		  
		  		 <span style="color:#303A43;"> 发布商家:</span><span style="color:#666666;">&nbsp;<%=compnay%></span>             
		  		 <div style="margin-top:8px;"></div>         
                 <span style="color:#303A43;">商品分类:</span><span style="color:#666666;">&nbsp;<%=catAttr.toString()%></span>          
  		  </td>
			  <td width="10%"><%=remark%></td>	
		  	<td width="10%"><%=state_codex%></td>			  	  	
				<td width="10%">
		 	   <a href="updateInfo.jsp?goods_id=<%=goods_id %>">审核</a> | <a href="javascript:deleteOneInfo('<%=goods_id%>','2729');">删除</a>
		 		</td>
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0"  class="dl_bg">
		<tr>
			<td width="85%">
			 
			   <select name="dw_operating" id="dw_operating">
				 <option value="">请选择...</option>	
				 <option value="-">删除</option>	
				 <option value="c">审核通过</option>
				 <option value="b">审核不通过</option>
				</select>	
				
				<input type="button" name="delInfo" onClick="delIndexInfos('dw')" value="确定"  class="buttab" />
				
				
		    
			</td>
			<td>
				
				总计:<%=counter %>条
			  
			  <%if(listOrImg.equals("1")){%>
				<a href="index.jsp?listOrImg=0&iStart=<%=Integer.parseInt(iStart)%>"><img src="/program/admin/images/Onlist.jpg" style="cursor:pointer;" border="0" title="列表显示" /></a>
				<img src="/program/admin/images/Unimglist.jpg" style="cursor:pointer;" border="0" title="图文显示" />
				<%}else if(listOrImg.equals("0")){%>
				<img src="/program/admin/images/Outlist.jpg" style="cursor:pointer;" border="0" title="列表显示" />
				<a href="index.jsp?listOrImg=0&iStart=<%=Integer.parseInt(iStart)%>"><img src="/program/admin/images/Imglist.jpg" style="cursor:pointer;" border="0" title="图文显示" /></a>
				<%}%>

			
			
			
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td align="center"><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	
	<input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
	<input type="hidden" name="pkid" id="pkid" value="" />
	<input type="hidden" name="state_code" id="state_code" value="" />
	<input type="hidden" name="bpm_id" id="bpm_id" value="" />
    <input type="hidden" name="statecode" id="statecode" value="" />
    <input type="hidden" name="pk_state" id="pk_state" value="" />
    <input type="hidden" name="pk_price" id="pk_price" value="" />
    <input type="hidden" name="allprice" id="allprice" value="" />
    <input type="hidden" name="memberprice" id="memberprice" value="" />
    <input type="hidden" name="one_member_price" id="one_member_price" value="" />
    <input type="hidden" name="selmethod" id="selmethod" value="" />
    <input type="hidden" name="state_name" id="state_name" value="" />
    
    <input type="hidden" name="send_intermethod" id="send_intermethod" value="" />
    <input type="hidden" name="allsend_inter" id="allsend_inter" value="" />
    <input type="hidden" name="pk_send_inter" id="pk_send_inter" value="" />
                                                       
   </form>
</body>

</html>
